home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / coreaids.arc / PARM_BRK.ASM < prev    next >
Assembly Source File  |  1988-11-20  |  2KB  |  76 lines

  1. ;    DESC:    Takes in parameter string retrieved from DOS level   V1.00
  2. ;        and breaks the string into separate elements using
  3. ;        commas and the end of line as the only breaks.
  4. ;    IN:    *{SEG_VAL} segment and
  5. ;        *{OFFSET} offset of parameter string
  6. ;        *{LENGTH} length of parameter string
  7. ;    OUT:    *{N} n is the number of sets of segment,offset  and length
  8. ;         groups returned, which indicates the number of total
  9. ;         parameters passed to the program.
  10. ;        *{OSEG_VAL,OOFFSET,OLENGTH} repeated N times
  11. ;         and returned in reverse order (i.e. P3, P2 , P1)
  12. ;    SAMPLE:    Callm    PARM_BRK,<SEG_VAL,OFFSET,LENGTH>,
  13. ;                         <N,<OSEG_VAL,OOFFSET,OLENGTH>>
  14. ;    ################################################################### 
  15.  
  16.     Extrn    PUSHALL:Near
  17.     Extrn    POPALL:Near
  18.     Extrn    SCAN_BYT:Near
  19.  
  20.  
  21. PARM_BRC    Segment Para Public 'CODE'
  22.     Assume    CS:PARM_BRC
  23.     Public    PARM_BRK
  24.  
  25.     Include    CALLM.MAC
  26.  
  27.                         ;notice.
  28.     DB    'PARM_BRK - V1.00, Copyright 1987, CoreTechs   ',0DH,0AH
  29.  
  30. PARM_BRK    Proc    Near
  31.  
  32.     Call    PUSHALL                ;save registers.
  33.  
  34.     Pop    CX                ;recover length.
  35.     Pop    BP                ;recover offset.
  36.     Pop    ES                ;recover segment.
  37.  
  38.     Jcxz    OUT0                ;if no parameters exit.
  39.     Jmp    CONT1
  40. OUT0:    Jmp    OUT
  41.  
  42. CONT1:    Mov    CX,0                ;clear N.
  43.  
  44.                         ;scan for commas or spaces
  45.                         ;as the delimiting character.
  46. CONT2:    Cld                    ;in the forward direction.
  47.     Callm    SCAN_BYT,<',',ES,BP,0,2>,<AX,BX>
  48.  
  49.     Mov    DX,BX                ;save beginning of next
  50.     Inc    DX                ;parameter.
  51.  
  52.     Mov    ES:BYTE PTR[BX],0        ;place zero byte at end.
  53.     Sub    BX,BP                ;find length of string.
  54.  
  55.     Push    BX
  56.     Push    BP
  57.     Push    ES
  58.  
  59.     Mov    BP,DX                ;move pointer along
  60.  
  61.     Inc    CX                ;increment N.
  62.  
  63.     Cmp    AX,0                ;if end of par. block
  64.     Jz    OUT                ;then return.
  65.  
  66.     Jmp    CONT2                ;else continue.
  67.  
  68. OUT:    Push    CX                ;save N.
  69.  
  70.     Call    POPALL                ;recover registers.
  71.     Ret
  72.  
  73. PARM_BRK    Endp
  74. PARM_BRC    Ends
  75.     End
  76.